package com.zhaopin.file;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;

import java.beans.Encoder;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @create 2020-03-02 10:49
 */
public class Read2jsonFile {

    public static void main(String[] args) throws IOException {
        // 读取文件1 2
        String oldPram = FileUtils.readFileToString(new File("E:\\zhaopin_doc\\日常流水\\pre.json"), "utf-8");
        String newPram = FileUtils.readFileToString(new File("E:\\zhaopin_doc\\日常流水\\online.json"), "utf-8");
        JSONArray jsonArrayPre = JSONObject.parseArray(oldPram);
        JSONArray jsonArrayOnline = JSONObject.parseArray(newPram);

        JSONObject json1 = new JSONObject();
        JSONObject json2 = new JSONObject();
        JSONObject json3 = new JSONObject();

        List<String> list1 = new ArrayList<>();
        List<String> list2 = new ArrayList<>();

        for (Object o : jsonArrayPre) {
            json1 = (JSONObject)o;
            String preId = json1.getString("positionId");
            list1.add(preId);
        }

        for (Object o : jsonArrayOnline) {
            json2 = (JSONObject)o;
            String onlineId = json2.getString("positionId");
            list2.add(onlineId);
        }

        for (int i = 0; i < list2.size(); i++) {
            if(!list1.contains(list2.get(i))){
                System.out.println("存在2不存在1中的：" + list2.get(i));
            }
        }



    }
}
